const express = require('express');
const router = express.Router();
const { getHealthData } = require('../controllers/health');

router.get('/:userId', 
  // 参数验证中间件
  (req, res, next) => {
    if (!/^user\d{3}$/.test(req.params.userId)) {
      return res.status(400).json({ 
        code: 400,
        message: "用户ID格式错误，应为user+3位数字" 
      });
    }
    next();
  },
  getHealthData
);

module.exports = router;
